3.71 \(\int \frac {(a+b \tan (e+f x))^2 (A+B \tan (e+f x)+C \tan ^2(e+f x))}{c+d \tan (e+f x)} \, dx\)

Optimal. Leaf size=236 \[ -\frac {\log (\cos (e+f x)) \left (a^2 (B c-d (A-C))+2 a b (A c+B d-c C)-b^2 (B c-d (A-C))\right )}{f \left (c^2+d^2\right )}+\frac {x \left (a^2 (A c+B d-c C)-2 a b (B c-d (A-C))-b^2 (A c+B d-c C)\right )}{c^2+d^2}+\frac {(b c-a d)^2 \left (A d^2-B c d+c^2 C\right ) \log (c+d \tan (e+f x))}{d^3 f \left (c^2+d^2\right )}-\frac {b \tan (e+f x) (-a C d-b B d+b c C)}{d^2 f}+\frac {C (a+b \tan (e+f x))^2}{2 d f} \]

[Out]

(a^2*(A*c+B*d-C*c)-b^2*(A*c+B*d-C*c)-2*a*b*(B*c-(A-C)*d))*x/(c^2+d^2)-(2*a*b*(A*c+B*d-C*c)+a^2*(B*c-(A-C)*d)-b
^2*(B*c-(A-C)*d))*ln(cos(f*x+e))/(c^2+d^2)/f+(-a*d+b*c)^2*(A*d^2-B*c*d+C*c^2)*ln(c+d*tan(f*x+e))/d^3/(c^2+d^2)
/f-b*(-B*b*d-C*a*d+C*b*c)*tan(f*x+e)/d^2/f+1/2*C*(a+b*tan(f*x+e))^2/d/f

________________________________________________________________________________________

Rubi [A]  time = 0.80, antiderivative size = 236, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 6, integrand size = 45, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.133, Rules used = {3647, 3637, 3626, 3617, 31, 3475} \[ -\frac {\log (\cos (e+f x)) \left (a^2 (B c-d (A-C))+2 a b (A c+B d-c C)-b^2 (B c-d (A-C))\right )}{f \left (c^2+d^2\right )}+\frac {x \left (a^2 (A c+B d-c C)-2 a b (B c-d (A-C))-b^2 (A c+B d-c C)\right )}{c^2+d^2}+\frac {(b c-a d)^2 \left (A d^2-B c d+c^2 C\right ) \log (c+d \tan (e+f x))}{d^3 f \left (c^2+d^2\right )}-\frac {b \tan (e+f x) (-a C d-b B d+b c C)}{d^2 f}+\frac {C (a+b \tan (e+f x))^2}{2 d f} \]

Antiderivative was successfully verified.

[In]

Int[((a + b*Tan[e + f*x])^2*(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2))/(c + d*Tan[e + f*x]),x]

[Out]

((a^2*(A*c - c*C + B*d) - b^2*(A*c - c*C + B*d) - 2*a*b*(B*c - (A - C)*d))*x)/(c^2 + d^2) - ((2*a*b*(A*c - c*C
 + B*d) + a^2*(B*c - (A - C)*d) - b^2*(B*c - (A - C)*d))*Log[Cos[e + f*x]])/((c^2 + d^2)*f) + ((b*c - a*d)^2*(
c^2*C - B*c*d + A*d^2)*Log[c + d*Tan[e + f*x]])/(d^3*(c^2 + d^2)*f) - (b*(b*c*C - b*B*d - a*C*d)*Tan[e + f*x])
/(d^2*f) + (C*(a + b*Tan[e + f*x])^2)/(2*d*f)

Rule 31

Int[((a_) + (b_.)*(x_))^(-1), x_Symbol] :> Simp[Log[RemoveContent[a + b*x, x]]/b, x] /; FreeQ[{a, b}, x]

Rule 3475

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> -Simp[Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3617

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_) + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Dist[
A/(b*f), Subst[Int[(a + x)^m, x], x, b*Tan[e + f*x]], x] /; FreeQ[{a, b, e, f, A, C, m}, x] && EqQ[A, C]

Rule 3626

Int[((A_) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2)/((a_.) + (b_.)*tan[(e_.) + (f_.)*
(x_)]), x_Symbol] :> Simp[((a*A + b*B - a*C)*x)/(a^2 + b^2), x] + (Dist[(A*b^2 - a*b*B + a^2*C)/(a^2 + b^2), I
nt[(1 + Tan[e + f*x]^2)/(a + b*Tan[e + f*x]), x], x] - Dist[(A*b - a*B - b*C)/(a^2 + b^2), Int[Tan[e + f*x], x
], x]) /; FreeQ[{a, b, e, f, A, B, C}, x] && NeQ[A*b^2 - a*b*B + a^2*C, 0] && NeQ[a^2 + b^2, 0] && NeQ[A*b - a
*B - b*C, 0]

Rule 3637

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^(n_.)*((A_.) + (B_.)*tan[(e
_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[(b*C*Tan[e + f*x]*(c + d*Tan[e + f*x])
^(n + 1))/(d*f*(n + 2)), x] - Dist[1/(d*(n + 2)), Int[(c + d*Tan[e + f*x])^n*Simp[b*c*C - a*A*d*(n + 2) - (A*b
 + a*B - b*C)*d*(n + 2)*Tan[e + f*x] - (a*C*d*(n + 2) - b*(c*C - B*d*(n + 2)))*Tan[e + f*x]^2, x], x], x] /; F
reeQ[{a, b, c, d, e, f, A, B, C, n}, x] && NeQ[b*c - a*d, 0] && NeQ[c^2 + d^2, 0] &&  !LtQ[n, -1]

Rule 3647

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^(n_)*((A_.) + (B_.)*
tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[(C*(a + b*Tan[e + f*x])^m*(c + d
*Tan[e + f*x])^(n + 1))/(d*f*(m + n + 1)), x] + Dist[1/(d*(m + n + 1)), Int[(a + b*Tan[e + f*x])^(m - 1)*(c +
d*Tan[e + f*x])^n*Simp[a*A*d*(m + n + 1) - C*(b*c*m + a*d*(n + 1)) + d*(A*b + a*B - b*C)*(m + n + 1)*Tan[e + f
*x] - (C*m*(b*c - a*d) - b*B*d*(m + n + 1))*Tan[e + f*x]^2, x], x], x] /; FreeQ[{a, b, c, d, e, f, A, B, C, n}
, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[c^2 + d^2, 0] && GtQ[m, 0] &&  !(IGtQ[n, 0] && ( !Intege
rQ[m] || (EqQ[c, 0] && NeQ[a, 0])))

Rubi steps

\begin {align*} \int \frac {(a+b \tan (e+f x))^2 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{c+d \tan (e+f x)} \, dx &=\frac {C (a+b \tan (e+f x))^2}{2 d f}+\frac {\int \frac {(a+b \tan (e+f x)) \left (-2 (b c C-a A d)+2 (A b+a B-b C) d \tan (e+f x)-2 (b c C-b B d-a C d) \tan ^2(e+f x)\right )}{c+d \tan (e+f x)} \, dx}{2 d}\\ &=-\frac {b (b c C-b B d-a C d) \tan (e+f x)}{d^2 f}+\frac {C (a+b \tan (e+f x))^2}{2 d f}-\frac {\int \frac {2 \left (2 a b c C d-a^2 A d^2-b^2 c (c C-B d)\right )-2 \left (a^2 B-b^2 B+2 a b (A-C)\right ) d^2 \tan (e+f x)-2 \left (a^2 C d^2-2 a b d (c C-B d)+b^2 \left (c^2 C-B c d+(A-C) d^2\right )\right ) \tan ^2(e+f x)}{c+d \tan (e+f x)} \, dx}{2 d^2}\\ &=\frac {\left (a^2 (A c-c C+B d)-b^2 (A c-c C+B d)-2 a b (B c-(A-C) d)\right ) x}{c^2+d^2}-\frac {b (b c C-b B d-a C d) \tan (e+f x)}{d^2 f}+\frac {C (a+b \tan (e+f x))^2}{2 d f}+\frac {\left ((b c-a d)^2 \left (c^2 C-B c d+A d^2\right )\right ) \int \frac {1+\tan ^2(e+f x)}{c+d \tan (e+f x)} \, dx}{d^2 \left (c^2+d^2\right )}+\frac {\left (2 a b (A c-c C+B d)+a^2 (B c-(A-C) d)-b^2 (B c-(A-C) d)\right ) \int \tan (e+f x) \, dx}{c^2+d^2}\\ &=\frac {\left (a^2 (A c-c C+B d)-b^2 (A c-c C+B d)-2 a b (B c-(A-C) d)\right ) x}{c^2+d^2}-\frac {\left (2 a b (A c-c C+B d)+a^2 (B c-(A-C) d)-b^2 (B c-(A-C) d)\right ) \log (\cos (e+f x))}{\left (c^2+d^2\right ) f}-\frac {b (b c C-b B d-a C d) \tan (e+f x)}{d^2 f}+\frac {C (a+b \tan (e+f x))^2}{2 d f}+\frac {\left ((b c-a d)^2 \left (c^2 C-B c d+A d^2\right )\right ) \operatorname {Subst}\left (\int \frac {1}{c+x} \, dx,x,d \tan (e+f x)\right )}{d^3 \left (c^2+d^2\right ) f}\\ &=\frac {\left (a^2 (A c-c C+B d)-b^2 (A c-c C+B d)-2 a b (B c-(A-C) d)\right ) x}{c^2+d^2}-\frac {\left (2 a b (A c-c C+B d)+a^2 (B c-(A-C) d)-b^2 (B c-(A-C) d)\right ) \log (\cos (e+f x))}{\left (c^2+d^2\right ) f}+\frac {(b c-a d)^2 \left (c^2 C-B c d+A d^2\right ) \log (c+d \tan (e+f x))}{d^3 \left (c^2+d^2\right ) f}-\frac {b (b c C-b B d-a C d) \tan (e+f x)}{d^2 f}+\frac {C (a+b \tan (e+f x))^2}{2 d f}\\ \end {align*}

________________________________________________________________________________________

Mathematica [C]  time = 2.99, size = 190, normalized size = 0.81 \[ \frac {\frac {2 (b c-a d)^2 \left (A d^2-B c d+c^2 C\right ) \log (c+d \tan (e+f x))}{d^2 \left (c^2+d^2\right )}+\frac {d (a-i b)^2 (i A+B-i C) \log (\tan (e+f x)+i)}{c-i d}+\frac {d (a+i b)^2 (-i A+B+i C) \log (-\tan (e+f x)+i)}{c+i d}+\frac {2 b \tan (e+f x) (a C d+b B d-b c C)}{d}+C (a+b \tan (e+f x))^2}{2 d f} \]

Antiderivative was successfully verified.

[In]

Integrate[((a + b*Tan[e + f*x])^2*(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2))/(c + d*Tan[e + f*x]),x]

[Out]

(((a + I*b)^2*((-I)*A + B + I*C)*d*Log[I - Tan[e + f*x]])/(c + I*d) + ((a - I*b)^2*(I*A + B - I*C)*d*Log[I + T
an[e + f*x]])/(c - I*d) + (2*(b*c - a*d)^2*(c^2*C - B*c*d + A*d^2)*Log[c + d*Tan[e + f*x]])/(d^2*(c^2 + d^2))
+ (2*b*(-(b*c*C) + b*B*d + a*C*d)*Tan[e + f*x])/d + C*(a + b*Tan[e + f*x])^2)/(2*d*f)

________________________________________________________________________________________

fricas [A]  time = 1.17, size = 390, normalized size = 1.65 \[ \frac {2 \, {\left ({\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} c d^{3} + {\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} d^{4}\right )} f x + {\left (C b^{2} c^{2} d^{2} + C b^{2} d^{4}\right )} \tan \left (f x + e\right )^{2} + {\left (C b^{2} c^{4} + A a^{2} d^{4} - {\left (2 \, C a b + B b^{2}\right )} c^{3} d + {\left (C a^{2} + 2 \, B a b + A b^{2}\right )} c^{2} d^{2} - {\left (B a^{2} + 2 \, A a b\right )} c d^{3}\right )} \log \left (\frac {d^{2} \tan \left (f x + e\right )^{2} + 2 \, c d \tan \left (f x + e\right ) + c^{2}}{\tan \left (f x + e\right )^{2} + 1}\right ) - {\left (C b^{2} c^{4} - {\left (2 \, C a b + B b^{2}\right )} c^{3} d + {\left (C a^{2} + 2 \, B a b + A b^{2}\right )} c^{2} d^{2} - {\left (2 \, C a b + B b^{2}\right )} c d^{3} + {\left (C a^{2} + 2 \, B a b + {\left (A - C\right )} b^{2}\right )} d^{4}\right )} \log \left (\frac {1}{\tan \left (f x + e\right )^{2} + 1}\right ) - 2 \, {\left (C b^{2} c^{3} d + C b^{2} c d^{3} - {\left (2 \, C a b + B b^{2}\right )} c^{2} d^{2} - {\left (2 \, C a b + B b^{2}\right )} d^{4}\right )} \tan \left (f x + e\right )}{2 \, {\left (c^{2} d^{3} + d^{5}\right )} f} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(f*x+e))^2*(A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e)),x, algorithm="fricas")

[Out]

1/2*(2*(((A - C)*a^2 - 2*B*a*b - (A - C)*b^2)*c*d^3 + (B*a^2 + 2*(A - C)*a*b - B*b^2)*d^4)*f*x + (C*b^2*c^2*d^
2 + C*b^2*d^4)*tan(f*x + e)^2 + (C*b^2*c^4 + A*a^2*d^4 - (2*C*a*b + B*b^2)*c^3*d + (C*a^2 + 2*B*a*b + A*b^2)*c
^2*d^2 - (B*a^2 + 2*A*a*b)*c*d^3)*log((d^2*tan(f*x + e)^2 + 2*c*d*tan(f*x + e) + c^2)/(tan(f*x + e)^2 + 1)) -
(C*b^2*c^4 - (2*C*a*b + B*b^2)*c^3*d + (C*a^2 + 2*B*a*b + A*b^2)*c^2*d^2 - (2*C*a*b + B*b^2)*c*d^3 + (C*a^2 +
2*B*a*b + (A - C)*b^2)*d^4)*log(1/(tan(f*x + e)^2 + 1)) - 2*(C*b^2*c^3*d + C*b^2*c*d^3 - (2*C*a*b + B*b^2)*c^2
*d^2 - (2*C*a*b + B*b^2)*d^4)*tan(f*x + e))/((c^2*d^3 + d^5)*f)

________________________________________________________________________________________

giac [A]  time = 3.06, size = 338, normalized size = 1.43 \[ \frac {\frac {2 \, {\left (A a^{2} c - C a^{2} c - 2 \, B a b c - A b^{2} c + C b^{2} c + B a^{2} d + 2 \, A a b d - 2 \, C a b d - B b^{2} d\right )} {\left (f x + e\right )}}{c^{2} + d^{2}} + \frac {{\left (B a^{2} c + 2 \, A a b c - 2 \, C a b c - B b^{2} c - A a^{2} d + C a^{2} d + 2 \, B a b d + A b^{2} d - C b^{2} d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{2} + d^{2}} + \frac {2 \, {\left (C b^{2} c^{4} - 2 \, C a b c^{3} d - B b^{2} c^{3} d + C a^{2} c^{2} d^{2} + 2 \, B a b c^{2} d^{2} + A b^{2} c^{2} d^{2} - B a^{2} c d^{3} - 2 \, A a b c d^{3} + A a^{2} d^{4}\right )} \log \left ({\left | d \tan \left (f x + e\right ) + c \right |}\right )}{c^{2} d^{3} + d^{5}} + \frac {C b^{2} d \tan \left (f x + e\right )^{2} - 2 \, C b^{2} c \tan \left (f x + e\right ) + 4 \, C a b d \tan \left (f x + e\right ) + 2 \, B b^{2} d \tan \left (f x + e\right )}{d^{2}}}{2 \, f} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(f*x+e))^2*(A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e)),x, algorithm="giac")

[Out]

1/2*(2*(A*a^2*c - C*a^2*c - 2*B*a*b*c - A*b^2*c + C*b^2*c + B*a^2*d + 2*A*a*b*d - 2*C*a*b*d - B*b^2*d)*(f*x +
e)/(c^2 + d^2) + (B*a^2*c + 2*A*a*b*c - 2*C*a*b*c - B*b^2*c - A*a^2*d + C*a^2*d + 2*B*a*b*d + A*b^2*d - C*b^2*
d)*log(tan(f*x + e)^2 + 1)/(c^2 + d^2) + 2*(C*b^2*c^4 - 2*C*a*b*c^3*d - B*b^2*c^3*d + C*a^2*c^2*d^2 + 2*B*a*b*
c^2*d^2 + A*b^2*c^2*d^2 - B*a^2*c*d^3 - 2*A*a*b*c*d^3 + A*a^2*d^4)*log(abs(d*tan(f*x + e) + c))/(c^2*d^3 + d^5
) + (C*b^2*d*tan(f*x + e)^2 - 2*C*b^2*c*tan(f*x + e) + 4*C*a*b*d*tan(f*x + e) + 2*B*b^2*d*tan(f*x + e))/d^2)/f

________________________________________________________________________________________

maple [B]  time = 0.29, size = 861, normalized size = 3.65 \[ -\frac {b^{2} C c \tan \left (f x +e \right )}{f \,d^{2}}-\frac {2 C \arctan \left (\tan \left (f x +e \right )\right ) a b d}{f \left (c^{2}+d^{2}\right )}+\frac {\ln \left (c +d \tan \left (f x +e \right )\right ) A \,c^{2} b^{2}}{f d \left (c^{2}+d^{2}\right )}+\frac {A \arctan \left (\tan \left (f x +e \right )\right ) a^{2} c}{f \left (c^{2}+d^{2}\right )}+\frac {2 A \arctan \left (\tan \left (f x +e \right )\right ) a b d}{f \left (c^{2}+d^{2}\right )}-\frac {2 B \arctan \left (\tan \left (f x +e \right )\right ) a b c}{f \left (c^{2}+d^{2}\right )}+\frac {2 \ln \left (c +d \tan \left (f x +e \right )\right ) B \,c^{2} a b}{f d \left (c^{2}+d^{2}\right )}-\frac {2 \ln \left (c +d \tan \left (f x +e \right )\right ) C \,c^{3} a b}{f \,d^{2} \left (c^{2}+d^{2}\right )}+\frac {\ln \left (1+\tan ^{2}\left (f x +e \right )\right ) B a b d}{f \left (c^{2}+d^{2}\right )}-\frac {\ln \left (1+\tan ^{2}\left (f x +e \right )\right ) C a b c}{f \left (c^{2}+d^{2}\right )}-\frac {\ln \left (c +d \tan \left (f x +e \right )\right ) B \,c^{3} b^{2}}{f \,d^{2} \left (c^{2}+d^{2}\right )}+\frac {\ln \left (c +d \tan \left (f x +e \right )\right ) C \,c^{2} a^{2}}{f d \left (c^{2}+d^{2}\right )}+\frac {\ln \left (c +d \tan \left (f x +e \right )\right ) C \,c^{4} b^{2}}{f \,d^{3} \left (c^{2}+d^{2}\right )}-\frac {2 \ln \left (c +d \tan \left (f x +e \right )\right ) A a c b}{f \left (c^{2}+d^{2}\right )}+\frac {\ln \left (1+\tan ^{2}\left (f x +e \right )\right ) A a b c}{f \left (c^{2}+d^{2}\right )}+\frac {b^{2} C \left (\tan ^{2}\left (f x +e \right )\right )}{2 f d}+\frac {b^{2} B \tan \left (f x +e \right )}{f d}+\frac {C \arctan \left (\tan \left (f x +e \right )\right ) b^{2} c}{f \left (c^{2}+d^{2}\right )}-\frac {\ln \left (c +d \tan \left (f x +e \right )\right ) B \,a^{2} c}{f \left (c^{2}+d^{2}\right )}-\frac {\ln \left (1+\tan ^{2}\left (f x +e \right )\right ) A \,a^{2} d}{2 f \left (c^{2}+d^{2}\right )}-\frac {B \arctan \left (\tan \left (f x +e \right )\right ) b^{2} d}{f \left (c^{2}+d^{2}\right )}-\frac {C \arctan \left (\tan \left (f x +e \right )\right ) a^{2} c}{f \left (c^{2}+d^{2}\right )}+\frac {2 b C \tan \left (f x +e \right ) a}{f d}-\frac {A \arctan \left (\tan \left (f x +e \right )\right ) b^{2} c}{f \left (c^{2}+d^{2}\right )}+\frac {d \ln \left (c +d \tan \left (f x +e \right )\right ) A \,a^{2}}{f \left (c^{2}+d^{2}\right )}+\frac {B \arctan \left (\tan \left (f x +e \right )\right ) a^{2} d}{f \left (c^{2}+d^{2}\right )}-\frac {\ln \left (1+\tan ^{2}\left (f x +e \right )\right ) C \,b^{2} d}{2 f \left (c^{2}+d^{2}\right )}-\frac {\ln \left (1+\tan ^{2}\left (f x +e \right )\right ) B \,b^{2} c}{2 f \left (c^{2}+d^{2}\right )}+\frac {\ln \left (1+\tan ^{2}\left (f x +e \right )\right ) C \,a^{2} d}{2 f \left (c^{2}+d^{2}\right )}+\frac {\ln \left (1+\tan ^{2}\left (f x +e \right )\right ) A \,b^{2} d}{2 f \left (c^{2}+d^{2}\right )}+\frac {\ln \left (1+\tan ^{2}\left (f x +e \right )\right ) B \,a^{2} c}{2 f \left (c^{2}+d^{2}\right )} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a+b*tan(f*x+e))^2*(A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e)),x)

[Out]

-1/f*b^2/d^2*C*c*tan(f*x+e)-1/2/f/(c^2+d^2)*ln(1+tan(f*x+e)^2)*C*b^2*d-1/2/f/(c^2+d^2)*ln(1+tan(f*x+e)^2)*A*a^
2*d-1/2/f/(c^2+d^2)*ln(1+tan(f*x+e)^2)*B*b^2*c+1/2/f/(c^2+d^2)*ln(1+tan(f*x+e)^2)*C*a^2*d-2/f/(c^2+d^2)*C*arct
an(tan(f*x+e))*a*b*d+1/f/d/(c^2+d^2)*ln(c+d*tan(f*x+e))*A*c^2*b^2+1/f/(c^2+d^2)*A*arctan(tan(f*x+e))*a^2*c+1/f
/(c^2+d^2)*ln(1+tan(f*x+e)^2)*A*a*b*c+1/f/(c^2+d^2)*ln(1+tan(f*x+e)^2)*B*a*b*d+2/f/(c^2+d^2)*A*arctan(tan(f*x+
e))*a*b*d-2/f/(c^2+d^2)*B*arctan(tan(f*x+e))*a*b*c+2/f/d/(c^2+d^2)*ln(c+d*tan(f*x+e))*B*c^2*a*b-2/f/d^2/(c^2+d
^2)*ln(c+d*tan(f*x+e))*C*c^3*a*b-1/f/d^2/(c^2+d^2)*ln(c+d*tan(f*x+e))*B*c^3*b^2+1/f/d/(c^2+d^2)*ln(c+d*tan(f*x
+e))*C*c^2*a^2+1/f/d^3/(c^2+d^2)*ln(c+d*tan(f*x+e))*C*c^4*b^2-1/f/(c^2+d^2)*ln(1+tan(f*x+e)^2)*C*a*b*c-2/f/(c^
2+d^2)*ln(c+d*tan(f*x+e))*A*a*c*b+1/f*b^2/d*B*tan(f*x+e)+1/f/(c^2+d^2)*C*arctan(tan(f*x+e))*b^2*c-1/f/(c^2+d^2
)*ln(c+d*tan(f*x+e))*B*a^2*c-1/f/(c^2+d^2)*B*arctan(tan(f*x+e))*b^2*d-1/f/(c^2+d^2)*C*arctan(tan(f*x+e))*a^2*c
+1/2/f/(c^2+d^2)*ln(1+tan(f*x+e)^2)*A*b^2*d+1/2/f/(c^2+d^2)*ln(1+tan(f*x+e)^2)*B*a^2*c+1/2/f*b^2/d*C*tan(f*x+e
)^2+2/f*b/d*C*tan(f*x+e)*a-1/f/(c^2+d^2)*A*arctan(tan(f*x+e))*b^2*c+1/f*d/(c^2+d^2)*ln(c+d*tan(f*x+e))*A*a^2+1
/f/(c^2+d^2)*B*arctan(tan(f*x+e))*a^2*d

________________________________________________________________________________________

maxima [A]  time = 0.55, size = 294, normalized size = 1.25 \[ \frac {\frac {2 \, {\left ({\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} c + {\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} d\right )} {\left (f x + e\right )}}{c^{2} + d^{2}} + \frac {2 \, {\left (C b^{2} c^{4} + A a^{2} d^{4} - {\left (2 \, C a b + B b^{2}\right )} c^{3} d + {\left (C a^{2} + 2 \, B a b + A b^{2}\right )} c^{2} d^{2} - {\left (B a^{2} + 2 \, A a b\right )} c d^{3}\right )} \log \left (d \tan \left (f x + e\right ) + c\right )}{c^{2} d^{3} + d^{5}} + \frac {{\left ({\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} c - {\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{2} + d^{2}} + \frac {C b^{2} d \tan \left (f x + e\right )^{2} - 2 \, {\left (C b^{2} c - {\left (2 \, C a b + B b^{2}\right )} d\right )} \tan \left (f x + e\right )}{d^{2}}}{2 \, f} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(f*x+e))^2*(A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e)),x, algorithm="maxima")

[Out]

1/2*(2*(((A - C)*a^2 - 2*B*a*b - (A - C)*b^2)*c + (B*a^2 + 2*(A - C)*a*b - B*b^2)*d)*(f*x + e)/(c^2 + d^2) + 2
*(C*b^2*c^4 + A*a^2*d^4 - (2*C*a*b + B*b^2)*c^3*d + (C*a^2 + 2*B*a*b + A*b^2)*c^2*d^2 - (B*a^2 + 2*A*a*b)*c*d^
3)*log(d*tan(f*x + e) + c)/(c^2*d^3 + d^5) + ((B*a^2 + 2*(A - C)*a*b - B*b^2)*c - ((A - C)*a^2 - 2*B*a*b - (A
- C)*b^2)*d)*log(tan(f*x + e)^2 + 1)/(c^2 + d^2) + (C*b^2*d*tan(f*x + e)^2 - 2*(C*b^2*c - (2*C*a*b + B*b^2)*d)
*tan(f*x + e))/d^2)/f

________________________________________________________________________________________

mupad [B]  time = 11.20, size = 325, normalized size = 1.38 \[ \frac {\mathrm {tan}\left (e+f\,x\right )\,\left (\frac {B\,b^2+2\,C\,a\,b}{d}-\frac {C\,b^2\,c}{d^2}\right )}{f}+\frac {\ln \left (c+d\,\mathrm {tan}\left (e+f\,x\right )\right )\,\left (d^2\,\left (C\,a^2\,c^2+2\,B\,a\,b\,c^2+A\,b^2\,c^2\right )-d\,\left (B\,b^2\,c^3+2\,C\,a\,b\,c^3\right )-d^3\,\left (B\,c\,a^2+2\,A\,b\,c\,a\right )+A\,a^2\,d^4+C\,b^2\,c^4\right )}{f\,\left (c^2\,d^3+d^5\right )}+\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\left (A\,b^2-A\,a^2+B\,a^2\,1{}\mathrm {i}-B\,b^2\,1{}\mathrm {i}+C\,a^2-C\,b^2+A\,a\,b\,2{}\mathrm {i}+2\,B\,a\,b-C\,a\,b\,2{}\mathrm {i}\right )}{2\,f\,\left (d+c\,1{}\mathrm {i}\right )}+\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )-\mathrm {i}\right )\,\left (B\,a^2-B\,b^2+2\,A\,a\,b-2\,C\,a\,b-A\,a^2\,1{}\mathrm {i}+A\,b^2\,1{}\mathrm {i}+C\,a^2\,1{}\mathrm {i}-C\,b^2\,1{}\mathrm {i}+B\,a\,b\,2{}\mathrm {i}\right )}{2\,f\,\left (c+d\,1{}\mathrm {i}\right )}+\frac {C\,b^2\,{\mathrm {tan}\left (e+f\,x\right )}^2}{2\,d\,f} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(((a + b*tan(e + f*x))^2*(A + B*tan(e + f*x) + C*tan(e + f*x)^2))/(c + d*tan(e + f*x)),x)

[Out]

(tan(e + f*x)*((B*b^2 + 2*C*a*b)/d - (C*b^2*c)/d^2))/f + (log(c + d*tan(e + f*x))*(d^2*(A*b^2*c^2 + C*a^2*c^2
+ 2*B*a*b*c^2) - d*(B*b^2*c^3 + 2*C*a*b*c^3) - d^3*(B*a^2*c + 2*A*a*b*c) + A*a^2*d^4 + C*b^2*c^4))/(f*(d^5 + c
^2*d^3)) + (log(tan(e + f*x) + 1i)*(A*b^2 - A*a^2 + B*a^2*1i - B*b^2*1i + C*a^2 - C*b^2 + A*a*b*2i + 2*B*a*b -
 C*a*b*2i))/(2*f*(c*1i + d)) + (log(tan(e + f*x) - 1i)*(A*b^2*1i - A*a^2*1i + B*a^2 - B*b^2 + C*a^2*1i - C*b^2
*1i + 2*A*a*b + B*a*b*2i - 2*C*a*b))/(2*f*(c + d*1i)) + (C*b^2*tan(e + f*x)^2)/(2*d*f)

________________________________________________________________________________________

sympy [A]  time = 8.13, size = 4517, normalized size = 19.14 \[ \text {result too large to display} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(f*x+e))**2*(A+B*tan(f*x+e)+C*tan(f*x+e)**2)/(c+d*tan(f*x+e)),x)

[Out]

Piecewise((zoo*x*(a + b*tan(e))**2*(A + B*tan(e) + C*tan(e)**2)/tan(e), Eq(c, 0) & Eq(d, 0) & Eq(f, 0)), (-I*A
*a**2*f*x*tan(e + f*x)/(-2*d*f*tan(e + f*x) + 2*I*d*f) - A*a**2*f*x/(-2*d*f*tan(e + f*x) + 2*I*d*f) - I*A*a**2
/(-2*d*f*tan(e + f*x) + 2*I*d*f) - 2*A*a*b*f*x*tan(e + f*x)/(-2*d*f*tan(e + f*x) + 2*I*d*f) + 2*I*A*a*b*f*x/(-
2*d*f*tan(e + f*x) + 2*I*d*f) + 2*A*a*b/(-2*d*f*tan(e + f*x) + 2*I*d*f) - I*A*b**2*f*x*tan(e + f*x)/(-2*d*f*ta
n(e + f*x) + 2*I*d*f) - A*b**2*f*x/(-2*d*f*tan(e + f*x) + 2*I*d*f) - A*b**2*log(tan(e + f*x)**2 + 1)*tan(e + f
*x)/(-2*d*f*tan(e + f*x) + 2*I*d*f) + I*A*b**2*log(tan(e + f*x)**2 + 1)/(-2*d*f*tan(e + f*x) + 2*I*d*f) + I*A*
b**2/(-2*d*f*tan(e + f*x) + 2*I*d*f) - B*a**2*f*x*tan(e + f*x)/(-2*d*f*tan(e + f*x) + 2*I*d*f) + I*B*a**2*f*x/
(-2*d*f*tan(e + f*x) + 2*I*d*f) + B*a**2/(-2*d*f*tan(e + f*x) + 2*I*d*f) - 2*I*B*a*b*f*x*tan(e + f*x)/(-2*d*f*
tan(e + f*x) + 2*I*d*f) - 2*B*a*b*f*x/(-2*d*f*tan(e + f*x) + 2*I*d*f) - 2*B*a*b*log(tan(e + f*x)**2 + 1)*tan(e
 + f*x)/(-2*d*f*tan(e + f*x) + 2*I*d*f) + 2*I*B*a*b*log(tan(e + f*x)**2 + 1)/(-2*d*f*tan(e + f*x) + 2*I*d*f) +
 2*I*B*a*b/(-2*d*f*tan(e + f*x) + 2*I*d*f) + 3*B*b**2*f*x*tan(e + f*x)/(-2*d*f*tan(e + f*x) + 2*I*d*f) - 3*I*B
*b**2*f*x/(-2*d*f*tan(e + f*x) + 2*I*d*f) - I*B*b**2*log(tan(e + f*x)**2 + 1)*tan(e + f*x)/(-2*d*f*tan(e + f*x
) + 2*I*d*f) - B*b**2*log(tan(e + f*x)**2 + 1)/(-2*d*f*tan(e + f*x) + 2*I*d*f) - 2*B*b**2*tan(e + f*x)**2/(-2*
d*f*tan(e + f*x) + 2*I*d*f) - 3*B*b**2/(-2*d*f*tan(e + f*x) + 2*I*d*f) - I*C*a**2*f*x*tan(e + f*x)/(-2*d*f*tan
(e + f*x) + 2*I*d*f) - C*a**2*f*x/(-2*d*f*tan(e + f*x) + 2*I*d*f) - C*a**2*log(tan(e + f*x)**2 + 1)*tan(e + f*
x)/(-2*d*f*tan(e + f*x) + 2*I*d*f) + I*C*a**2*log(tan(e + f*x)**2 + 1)/(-2*d*f*tan(e + f*x) + 2*I*d*f) + I*C*a
**2/(-2*d*f*tan(e + f*x) + 2*I*d*f) + 6*C*a*b*f*x*tan(e + f*x)/(-2*d*f*tan(e + f*x) + 2*I*d*f) - 6*I*C*a*b*f*x
/(-2*d*f*tan(e + f*x) + 2*I*d*f) - 2*I*C*a*b*log(tan(e + f*x)**2 + 1)*tan(e + f*x)/(-2*d*f*tan(e + f*x) + 2*I*
d*f) - 2*C*a*b*log(tan(e + f*x)**2 + 1)/(-2*d*f*tan(e + f*x) + 2*I*d*f) - 4*C*a*b*tan(e + f*x)**2/(-2*d*f*tan(
e + f*x) + 2*I*d*f) - 6*C*a*b/(-2*d*f*tan(e + f*x) + 2*I*d*f) + 3*I*C*b**2*f*x*tan(e + f*x)/(-2*d*f*tan(e + f*
x) + 2*I*d*f) + 3*C*b**2*f*x/(-2*d*f*tan(e + f*x) + 2*I*d*f) + 2*C*b**2*log(tan(e + f*x)**2 + 1)*tan(e + f*x)/
(-2*d*f*tan(e + f*x) + 2*I*d*f) - 2*I*C*b**2*log(tan(e + f*x)**2 + 1)/(-2*d*f*tan(e + f*x) + 2*I*d*f) - C*b**2
*tan(e + f*x)**3/(-2*d*f*tan(e + f*x) + 2*I*d*f) - I*C*b**2*tan(e + f*x)**2/(-2*d*f*tan(e + f*x) + 2*I*d*f) -
3*I*C*b**2/(-2*d*f*tan(e + f*x) + 2*I*d*f), Eq(c, -I*d)), (I*A*a**2*f*x*tan(e + f*x)/(-2*d*f*tan(e + f*x) - 2*
I*d*f) - A*a**2*f*x/(-2*d*f*tan(e + f*x) - 2*I*d*f) + I*A*a**2/(-2*d*f*tan(e + f*x) - 2*I*d*f) - 2*A*a*b*f*x*t
an(e + f*x)/(-2*d*f*tan(e + f*x) - 2*I*d*f) - 2*I*A*a*b*f*x/(-2*d*f*tan(e + f*x) - 2*I*d*f) + 2*A*a*b/(-2*d*f*
tan(e + f*x) - 2*I*d*f) + I*A*b**2*f*x*tan(e + f*x)/(-2*d*f*tan(e + f*x) - 2*I*d*f) - A*b**2*f*x/(-2*d*f*tan(e
 + f*x) - 2*I*d*f) - A*b**2*log(tan(e + f*x)**2 + 1)*tan(e + f*x)/(-2*d*f*tan(e + f*x) - 2*I*d*f) - I*A*b**2*l
og(tan(e + f*x)**2 + 1)/(-2*d*f*tan(e + f*x) - 2*I*d*f) - I*A*b**2/(-2*d*f*tan(e + f*x) - 2*I*d*f) - B*a**2*f*
x*tan(e + f*x)/(-2*d*f*tan(e + f*x) - 2*I*d*f) - I*B*a**2*f*x/(-2*d*f*tan(e + f*x) - 2*I*d*f) + B*a**2/(-2*d*f
*tan(e + f*x) - 2*I*d*f) + 2*I*B*a*b*f*x*tan(e + f*x)/(-2*d*f*tan(e + f*x) - 2*I*d*f) - 2*B*a*b*f*x/(-2*d*f*ta
n(e + f*x) - 2*I*d*f) - 2*B*a*b*log(tan(e + f*x)**2 + 1)*tan(e + f*x)/(-2*d*f*tan(e + f*x) - 2*I*d*f) - 2*I*B*
a*b*log(tan(e + f*x)**2 + 1)/(-2*d*f*tan(e + f*x) - 2*I*d*f) - 2*I*B*a*b/(-2*d*f*tan(e + f*x) - 2*I*d*f) + 3*B
*b**2*f*x*tan(e + f*x)/(-2*d*f*tan(e + f*x) - 2*I*d*f) + 3*I*B*b**2*f*x/(-2*d*f*tan(e + f*x) - 2*I*d*f) + I*B*
b**2*log(tan(e + f*x)**2 + 1)*tan(e + f*x)/(-2*d*f*tan(e + f*x) - 2*I*d*f) - B*b**2*log(tan(e + f*x)**2 + 1)/(
-2*d*f*tan(e + f*x) - 2*I*d*f) - 2*B*b**2*tan(e + f*x)**2/(-2*d*f*tan(e + f*x) - 2*I*d*f) - 3*B*b**2/(-2*d*f*t
an(e + f*x) - 2*I*d*f) + I*C*a**2*f*x*tan(e + f*x)/(-2*d*f*tan(e + f*x) - 2*I*d*f) - C*a**2*f*x/(-2*d*f*tan(e
+ f*x) - 2*I*d*f) - C*a**2*log(tan(e + f*x)**2 + 1)*tan(e + f*x)/(-2*d*f*tan(e + f*x) - 2*I*d*f) - I*C*a**2*lo
g(tan(e + f*x)**2 + 1)/(-2*d*f*tan(e + f*x) - 2*I*d*f) - I*C*a**2/(-2*d*f*tan(e + f*x) - 2*I*d*f) + 6*C*a*b*f*
x*tan(e + f*x)/(-2*d*f*tan(e + f*x) - 2*I*d*f) + 6*I*C*a*b*f*x/(-2*d*f*tan(e + f*x) - 2*I*d*f) + 2*I*C*a*b*log
(tan(e + f*x)**2 + 1)*tan(e + f*x)/(-2*d*f*tan(e + f*x) - 2*I*d*f) - 2*C*a*b*log(tan(e + f*x)**2 + 1)/(-2*d*f*
tan(e + f*x) - 2*I*d*f) - 4*C*a*b*tan(e + f*x)**2/(-2*d*f*tan(e + f*x) - 2*I*d*f) - 6*C*a*b/(-2*d*f*tan(e + f*
x) - 2*I*d*f) - 3*I*C*b**2*f*x*tan(e + f*x)/(-2*d*f*tan(e + f*x) - 2*I*d*f) + 3*C*b**2*f*x/(-2*d*f*tan(e + f*x
) - 2*I*d*f) + 2*C*b**2*log(tan(e + f*x)**2 + 1)*tan(e + f*x)/(-2*d*f*tan(e + f*x) - 2*I*d*f) + 2*I*C*b**2*log
(tan(e + f*x)**2 + 1)/(-2*d*f*tan(e + f*x) - 2*I*d*f) - C*b**2*tan(e + f*x)**3/(-2*d*f*tan(e + f*x) - 2*I*d*f)
 + I*C*b**2*tan(e + f*x)**2/(-2*d*f*tan(e + f*x) - 2*I*d*f) + 3*I*C*b**2/(-2*d*f*tan(e + f*x) - 2*I*d*f), Eq(c
, I*d)), ((A*a**2*x + A*a*b*log(tan(e + f*x)**2 + 1)/f - A*b**2*x + A*b**2*tan(e + f*x)/f + B*a**2*log(tan(e +
 f*x)**2 + 1)/(2*f) - 2*B*a*b*x + 2*B*a*b*tan(e + f*x)/f - B*b**2*log(tan(e + f*x)**2 + 1)/(2*f) + B*b**2*tan(
e + f*x)**2/(2*f) - C*a**2*x + C*a**2*tan(e + f*x)/f - C*a*b*log(tan(e + f*x)**2 + 1)/f + C*a*b*tan(e + f*x)**
2/f + C*b**2*x + C*b**2*tan(e + f*x)**3/(3*f) - C*b**2*tan(e + f*x)/f)/c, Eq(d, 0)), (x*(a + b*tan(e))**2*(A +
 B*tan(e) + C*tan(e)**2)/(c + d*tan(e)), Eq(f, 0)), (2*A*a**2*c*d**3*f*x/(2*c**2*d**3*f + 2*d**5*f) + 2*A*a**2
*d**4*log(c/d + tan(e + f*x))/(2*c**2*d**3*f + 2*d**5*f) - A*a**2*d**4*log(tan(e + f*x)**2 + 1)/(2*c**2*d**3*f
 + 2*d**5*f) - 4*A*a*b*c*d**3*log(c/d + tan(e + f*x))/(2*c**2*d**3*f + 2*d**5*f) + 2*A*a*b*c*d**3*log(tan(e +
f*x)**2 + 1)/(2*c**2*d**3*f + 2*d**5*f) + 4*A*a*b*d**4*f*x/(2*c**2*d**3*f + 2*d**5*f) + 2*A*b**2*c**2*d**2*log
(c/d + tan(e + f*x))/(2*c**2*d**3*f + 2*d**5*f) - 2*A*b**2*c*d**3*f*x/(2*c**2*d**3*f + 2*d**5*f) + A*b**2*d**4
*log(tan(e + f*x)**2 + 1)/(2*c**2*d**3*f + 2*d**5*f) - 2*B*a**2*c*d**3*log(c/d + tan(e + f*x))/(2*c**2*d**3*f
+ 2*d**5*f) + B*a**2*c*d**3*log(tan(e + f*x)**2 + 1)/(2*c**2*d**3*f + 2*d**5*f) + 2*B*a**2*d**4*f*x/(2*c**2*d*
*3*f + 2*d**5*f) + 4*B*a*b*c**2*d**2*log(c/d + tan(e + f*x))/(2*c**2*d**3*f + 2*d**5*f) - 4*B*a*b*c*d**3*f*x/(
2*c**2*d**3*f + 2*d**5*f) + 2*B*a*b*d**4*log(tan(e + f*x)**2 + 1)/(2*c**2*d**3*f + 2*d**5*f) - 2*B*b**2*c**3*d
*log(c/d + tan(e + f*x))/(2*c**2*d**3*f + 2*d**5*f) + 2*B*b**2*c**2*d**2*tan(e + f*x)/(2*c**2*d**3*f + 2*d**5*
f) - B*b**2*c*d**3*log(tan(e + f*x)**2 + 1)/(2*c**2*d**3*f + 2*d**5*f) - 2*B*b**2*d**4*f*x/(2*c**2*d**3*f + 2*
d**5*f) + 2*B*b**2*d**4*tan(e + f*x)/(2*c**2*d**3*f + 2*d**5*f) + 2*C*a**2*c**2*d**2*log(c/d + tan(e + f*x))/(
2*c**2*d**3*f + 2*d**5*f) - 2*C*a**2*c*d**3*f*x/(2*c**2*d**3*f + 2*d**5*f) + C*a**2*d**4*log(tan(e + f*x)**2 +
 1)/(2*c**2*d**3*f + 2*d**5*f) - 4*C*a*b*c**3*d*log(c/d + tan(e + f*x))/(2*c**2*d**3*f + 2*d**5*f) + 4*C*a*b*c
**2*d**2*tan(e + f*x)/(2*c**2*d**3*f + 2*d**5*f) - 2*C*a*b*c*d**3*log(tan(e + f*x)**2 + 1)/(2*c**2*d**3*f + 2*
d**5*f) - 4*C*a*b*d**4*f*x/(2*c**2*d**3*f + 2*d**5*f) + 4*C*a*b*d**4*tan(e + f*x)/(2*c**2*d**3*f + 2*d**5*f) +
 2*C*b**2*c**4*log(c/d + tan(e + f*x))/(2*c**2*d**3*f + 2*d**5*f) - 2*C*b**2*c**3*d*tan(e + f*x)/(2*c**2*d**3*
f + 2*d**5*f) + C*b**2*c**2*d**2*tan(e + f*x)**2/(2*c**2*d**3*f + 2*d**5*f) + 2*C*b**2*c*d**3*f*x/(2*c**2*d**3
*f + 2*d**5*f) - 2*C*b**2*c*d**3*tan(e + f*x)/(2*c**2*d**3*f + 2*d**5*f) - C*b**2*d**4*log(tan(e + f*x)**2 + 1
)/(2*c**2*d**3*f + 2*d**5*f) + C*b**2*d**4*tan(e + f*x)**2/(2*c**2*d**3*f + 2*d**5*f), True))

________________________________________________________________________________________